<?php
namespace api\modules\v1\controllers;

use api\modules\v1\models\coin\CoinRechargeOrder;
use api\modules\v1\models\coin\CoinRechargeSetting;
use api\modules\v1\models\userLevel\UserLevel;
use api\modules\v1\models\userLevel\UserLevelOrder;
use yii\filters\auth\HttpHeaderAuth;
use yii\helpers\ArrayHelper;

class CoinController extends DefaultController
{
    public $modelClass = 'api\modules\v1\models\user\UserLevel';

    public function behaviors() {
        return ArrayHelper::merge(parent::behaviors(), [
            'authenticator' => [
                'class' =>  HttpHeaderAuth::className(),
                'header' => 'access-token',
                'optional' => [

                ]
            ]
        ]);
    }

    public function actionList() {
        if (\Yii::$app->request->isGet) {
            return (new CoinRechargeSetting())->getList();
        }
    }

    public function actionOrder($page = 1, $size = 10) {
        if (\Yii::$app->request->isPost) {
            return (new CoinRechargeOrder())->createOrder();
        }

        if (\Yii::$app->request->isGet) {
            return (new CoinRechargeOrder())->getList($page, $size);
        }
    }
}
